package com.song.tools.core.exception;

import lombok.Getter;
import lombok.ToString;

import java.io.Serial;

/**
 * 非检查异常基类
 *
 * @author song tools
 * @since 2024-06-06
 */
@Getter
@ToString
public class BaseUncheckedException extends RuntimeException implements BaseException {

    @Serial
    private static final long serialVersionUID = -9146026889375528787L;

    /**
     * 异常信息
     */
    private String message;

    /**
     * 具体异常码
     */
    private final String code;

    public BaseUncheckedException(final String code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    public BaseUncheckedException(final String code, final String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BaseUncheckedException(ExceptionCode exceptionCode) {
        this(exceptionCode.getCode(), exceptionCode.getDesc());
    }
}
